package com.gxa.controller;

import com.gxa.pojo.Fp;
import com.gxa.utils.Constants;
import com.gxa.utils.ResponseData;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 * User: tx
 * Date: 2020/11/26 17:08
 * Description:
 * Version: V1.0
 */
@RestController
@Api(value = "模板消息",tags = "模板消息")
@RequestMapping(value = "options")
public class TemplateController {

    @Autowired
    private ResponseData responseData;
    @Autowired(required = false)
    private Constants constants;

    @PostMapping("/addTemplate")
    @ApiOperation(value = "添加模板消息",notes = "根据提交的信息添加模板消息",httpMethod = "POST",response = ResponseData.class)
    @ApiResponses({
            @ApiResponse(code = 200, message = "添加成功"),
            @ApiResponse(code = 400, message = "找不到页面"),
            @ApiResponse(code = 500, message = "添加失败")
    })
    public ResponseData addTemplate(@RequestBody @ApiParam(name = "fp",value = "模板消息",required = true) Fp fp){
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("添加成功");
        responseData.setData(fp);
        return responseData;
    }



    @GetMapping("/delTemplate")
    @ApiOperation(value = "删除模板消息",notes = "根据提交的信息删除模板消息",httpMethod = "GET",response = ResponseData.class)
    @ApiResponses({
            @ApiResponse(code = 200, message = "删除成功"),
            @ApiResponse(code = 400, message = "找不到页面"),
            @ApiResponse(code = 500, message = "删除失败")
    })
    public ResponseData delTemplate(@ApiParam(name = "fpId",value = "模板消息id",required = true) int fpId){
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("删除成功");
        responseData.setData(fpId);
        return responseData;
    }




    @GetMapping("/updateTemplate")
    @ApiOperation(value = "修改模板消息",notes = "根据提交的信息修改模板消息",httpMethod = "GET",response = ResponseData.class)
    @ApiResponses({
            @ApiResponse(code = 200, message = "修改成功"),
            @ApiResponse(code = 400, message = "找不到页面"),
            @ApiResponse(code = 500, message = "修改失败")
    })
    public ResponseData updateTemplate(@ApiParam(name = "fpId",value = "模板消息id",required = true) int fpId){
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("修改成功");
        responseData.setData(fpId);
        return responseData;
    }



    @PostMapping("/queryTemplate")
    @ApiOperation(value = "查询模板消息",notes = "根据提交的信息查询模板消息",httpMethod = "POST",response = ResponseData.class)
    @ApiResponses({
            @ApiResponse(code = 200, message = "查询成功"),
            @ApiResponse(code = 400, message = "找不到页面"),
            @ApiResponse(code = 500, message = "查询失败")
    })
    public ResponseData queryTemplate(@ApiParam(name = "fp",value = "模板消息",required = true) Fp fp){
        fp.setFpClass("类型1");
        fp.setFpName("标题1");
        fp.setFpDesc("备注1");
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(fp);
        return responseData;
    }
}
